/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package jpaintball;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

/**
 *
 * @author ondra
 */
public class GameMenu extends JMenuBar {

    GameWindow parent;

    GameMenu(GameWindow _parent) {
        super();
        parent = _parent;

        // ==================== GAME
        JMenu menu = new JMenu("Game");

        JMenuItem item = new JMenuItem("Join network game");
        item.addActionListener(new JoinListener());
        menu.add(item);

        // ---------------------------------
        menu.addSeparator();
        // ---------------------------------

        menu.add(new JMenuItem("Exit"));
        add(menu);

        // ==================== SERVER
        menu = new JMenu("Server");

        item = new JMenuItem("Start game server");
        item.addActionListener(new StartServerListener());
        menu.add(item);

        item = new JMenuItem("Stop game server");
        item.addActionListener(new StopServerListener());
        menu.add(item);
        add(menu);

        // ==================== HELP
        menu = new JMenu("Help");
        menu.add(new JMenuItem("How to play"));
        menu.add(new JMenuItem("About"));
        add(menu);
    }

    private class StartServerListener implements ActionListener {

        public void actionPerformed(ActionEvent arg0) {
            parent.showStartServerDialog();
        }

    }
    private class StopServerListener implements ActionListener {

        public void actionPerformed(ActionEvent arg0) {
            parent.stopServer();
        }

    }
    private class JoinListener implements ActionListener {

        public void actionPerformed(ActionEvent arg0) {
            parent.showJoinDialog();
        }

    }



}
